<?php


use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Str;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/error/noaccess', [\App\Http\Controllers\ErrorController::class,'noaccess']);

Route::middleware(['guest'])->group(function () {
    Route::get('/register', [\App\Http\Controllers\UserController::class,'register']);
    Route::post('/register', [\App\Http\Controllers\UserController::class,'doregister']);

    Route::get('/login', [\App\Http\Controllers\UserController::class,'login']);
    Route::post('/login', [\App\Http\Controllers\UserController::class,'dologin']);

    Route::get('/forget', [\App\Http\Controllers\UserController::class,'forget']);
    Route::post('/forget', [\App\Http\Controllers\UserController::class,'doforget']);
});

Route::middleware([])->group(function () {
    Route::get('/my', [\App\Http\Controllers\MyController::class,'index']);
    Route::get('/logout', [\App\Http\Controllers\MyController::class,'logout']);
});

Route::middleware(['adminguest'])->group(function () {
    Route::match(['get','post'],'/admin/login', 'App\Http\Controllers\Admin\IndexController@login');
});

Route::middleware(['adminauth'])->group(function () {
    Route::get('/admin/logout', 'App\Http\Controllers\Admin\IndexController@logout');
});

Route::middleware(['adminauth','adminrole'])->group(function () {
    Route::get('/admin/index', 'App\Http\Controllers\Admin\IndexController@layout');
    Route::get('/admin/index/index', 'App\Http\Controllers\Admin\IndexController@index');

    Route::match(['get','post'],'/admin/user/index', 'App\Http\Controllers\Admin\UserController@index')->name('admin.user');
    Route::match(['get','post'],'/admin/user/add', 'App\Http\Controllers\Admin\UserController@add');
    Route::match(['get','post'],'/admin/user/edit/{id}', 'App\Http\Controllers\Admin\UserController@edit')->where('id', '[0-9]+');
    Route::get('/admin/user/del/{id}', 'App\Http\Controllers\Admin\UserController@del')->where('id', '[0-9]+');
    Route::match(['get','post'],'/admin/user/{id}/role', 'App\Http\Controllers\Admin\UserController@role')->where('id', '[0-9]+');
    Route::match(['get','post'],'/admin/user/{id}/avatar', 'App\Http\Controllers\Admin\UserController@avatar')->where('id', '[0-9]+');

    Route::match(['get','post'],'/admin/role/index', 'App\Http\Controllers\Admin\RoleController@index')->name('admin.role');
    Route::match(['get','post'],'/admin/role/add', 'App\Http\Controllers\Admin\RoleController@add');
    Route::match(['get','post'],'/admin/role/edit/{id}', 'App\Http\Controllers\Admin\RoleController@edit')->where('id', '[0-9]+');
    Route::get('/admin/role/del/{id}', 'App\Http\Controllers\Admin\RoleController@del')->where('id', '[0-9]+');
    Route::match(['get','post'],'/admin/role/{id}/permission', 'App\Http\Controllers\Admin\RoleController@permission')->where('id', '[0-9]+');

    Route::match(['get','post'],'/admin/permission/index', 'App\Http\Controllers\Admin\PermissionController@index')->name('admin.permission');
    Route::match(['get','post'],'/admin/permission/add', 'App\Http\Controllers\Admin\PermissionController@add');
    Route::match(['get','post'],'/admin/permission/edit/{id}', 'App\Http\Controllers\Admin\PermissionController@edit')->where('id', '[0-9]+');
    Route::get('/admin/permission/del/{id}', 'App\Http\Controllers\Admin\PermissionController@del')->where('id', '[0-9]+');

    Route::match(['get','post'],'/admin/cache/index', 'App\Http\Controllers\Admin\CacheController@index')->name('admin.cache');
    Route::get('/admin/cache/flush', 'App\Http\Controllers\Admin\CacheController@flush');

    Route::match(['get','post'],'/admin/email/index', 'App\Http\Controllers\Admin\EmailController@index')->name('admin.email');
    Route::match(['get','post'],'/admin/email/edit', 'App\Http\Controllers\Admin\EmailController@edit');

    Route::match(['get','post'],'/admin/setting/index', 'App\Http\Controllers\Admin\SettingController@index')->name('admin.setting');
    Route::match(['get','post'],'/admin/setting/sms', 'App\Http\Controllers\Admin\SettingController@sms')->name('admin.sms');
    Route::match(['get','post'],'/admin/setting/wechat', 'App\Http\Controllers\Admin\SettingController@wechat')->name('admin.wechat');
    Route::match(['get','post'],'/admin/setting/oss', 'App\Http\Controllers\Admin\SettingController@oss')->name('admin.oss');
    Route::match(['get','post'],'/admin/setting/payali', 'App\Http\Controllers\Admin\SettingController@payali')->name('admin.payali');
    Route::match(['get','post'],'/admin/setting/paywechat', 'App\Http\Controllers\Admin\SettingController@paywechat')->name('admin.payali');

    Route::get('/admin/queue/index', 'App\Http\Controllers\Admin\QueueController@index')->name('admin.queue');
    Route::get('/admin/queue/failed', 'App\Http\Controllers\Admin\QueueController@failed');
    Route::match(['get','post'],'/admin/queue/set', 'App\Http\Controllers\Admin\QueueController@set');
    Route::get('/admin/queue/work', 'App\Http\Controllers\Admin\QueueController@work');

    Route::match(['get','post'],'/admin/api/index', 'App\Http\Controllers\Admin\ApiController@index')->name('admin.api');
    Route::match(['get','post'],'/admin/api/add', 'App\Http\Controllers\Admin\ApiController@add');
    Route::match(['get','post'],'/admin/api/edit/{id}', 'App\Http\Controllers\Admin\ApiController@edit')->where('id', '[0-9]+');
    Route::get('/admin/api/del/{id}', 'App\Http\Controllers\Admin\ApiController@del')->where('id', '[0-9]+');

});



Route::get('/mail', 'App\Http\Controllers\TestController@mail');
//Route::get('/notice', [\App\Http\Controllers\ErrorController::class,'Index']);
//Route::get('/test', 'App\Http\Controllers\TestController@index');
Route::get('/', 'App\Http\Controllers\Portal\IndexController@index');

Route::get('/params', function (Request $request){
    dd($request->all());
});

Route::get('common/smssend','App\Http\Controllers\Api\Common\SmsController@send');
Route::get('common/smscheck','App\Http\Controllers\Api\Common\SmsController@check');

Route::get('/test', function (){
    dd(config('G'));
    dd(app('pay.ali'));
    dd(Storage::disk('local'));
});
